package com.hz.ys_machineTaskInfo.dao;


import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.hz.framework.MyInterFace.SystemInterFace;
import com.hz.framework.dao.CommonDBDao;
import com.hz.framework.dao.CommonDao;
import com.hz.framework.util.DateUtil;
import com.hz.framework.util.SqlParameter;
import com.hz.supermanage.bean.Hzsyspersonnel;
import com.hz.ys_financial.bean.Takingsorpay;
import com.hz.ys_machineTaskInfo.bean.PresTrace;
import com.hz.ys_production.dbsql.DailyPaperSql;

/**
 * *****************************************************************************
 *               Copyright(c) 2010 by 哈尔滨华泽数码科技有限公司.
 *                       All rights reserved.
 *******************************************************************************
 *     File Name         :  com.hz.ys_stock.dao.PurchaseDao.java
 *     Description(说明)	:  追踪信息
 * -----------------------------------------------------------------------------
 *     No.        Date              Revised by           Description	  
 *     1		Jun 8, 2011				韩飞	              Created
 *****************************************************************************
 */
public class TraceDao implements SystemInterFace{
	
	/**
	 * @author 韩飞
	 * @time Nov 16, 2011	
	 * @param request
	 * @return 
	 * 方法功能: 根据 gid 查询 对应原材料信息
	 */
	public Map SelTrace_info(String orderid) throws Exception {
		CommonDao dbd= new CommonDao();
		String sql = "select o.orderid,o.clientid,o.name as ordername,c.unitAddress,t.* from orderinfo o left join clientinfo c on o.clientId = c.clientId " +
				" left join pres_trace t on o.orderid = t.orderid where o.orderid = ?";
		Map map = (Map)dbd.queryObjectByPS(sql, new SqlParameter(orderid),null);
		if(map.get("depotname")==null||"".equals(map.get("depotname"))){
			sql = "select * from pres_trace where clientid = ? order by tid ";
			Map old = (Map)dbd.queryObjectByPS(sql, new SqlParameter(map.get("clientid")),null);
			if(old!= null){
				map.put("depotname", old.get("depotname"));
				map.put("depotsite", old.get("depotsite"));
				map.put("depotpeople", old.get("depotpeople"));
				map.put("depotphone", old.get("depotphone"));
			}
		}
		return map;
	}
	
	/**
	 * @author 韩飞
	 * @time Nov 17, 2011	
	 * @param puser
	 * @return
	 * @throws Exception 
	 * 方法功能: 保存追踪信息
	 */
	public boolean DoSaveTrace( PresTrace pt ) throws Exception {
		boolean ins = false;
		CommonDao dbd= new CommonDao();
		if(pt!=null){
			ins = dbd.saveOrupdate(new SqlParameter(pt));
		}
		return ins;
	}
}
